package cn.hebutrun.oulabot.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 接口文档配置
 *
 * @author zhaolong
 */
@Configuration
@EnableSwagger2
@Profile("dev")
public class SwaggerConfig {

  @Bean
  public Docket defaultApi() {
    return new Docket(DocumentationType.SWAGGER_2)
        .apiInfo(
            new ApiInfoBuilder()
                .title("oula-bot")
                .description("# oula-bot")
                .termsOfServiceUrl("hebutrun.cn:9001/")
                .contact(new Contact("hebutrun", "hebutrun.cn", ""))
                .version("1.x")
                .build())
        // 分组名称
        .groupName("开发")
        .select()
        // 这里指定扫描包路径
        .apis(RequestHandlerSelectors.basePackage("cn.hebutrun.oulabot.controller"))
        .paths(PathSelectors.any())
        .build();
  }
}
